//瓦斯 特征值算法
package com.safety.algorithm.eigenvalue.gas;

import com.safety.algorithm.model.gas.GasAbsoluteEmissionModel;
import com.safety.algorithm.model.gas.GasAlgModel;
import com.safety.algorithm.model.gas.WindsAlgModel;

import java.util.ArrayList;
import java.util.List;

public class GasAlgorithm {
    //绝对瓦斯涌出量,实时取，输入一条瓦斯数据和对应的风速数据
    public List<GasAbsoluteEmissionModel> gasAbsEmission(GasAlgModel GasAlgModel, WindsAlgModel WindsAlgModel) {
        List<GasAbsoluteEmissionModel> result = new ArrayList<GasAbsoluteEmissionModel>();
        final int s = 1;//巷道断面面积s，可设置参数
        double q;//绝对瓦斯涌出量
        q = GasAlgModel.getMonitoringValue() * WindsAlgModel.getMonitoringValue() * s;
        GasAbsoluteEmissionModel gasAbsoluteEmissionModel =
                new GasAbsoluteEmissionModel(GasAlgModel.getDatetime(), GasAlgModel.getEntId(), q);
        result.add(gasAbsoluteEmissionModel);
        return result;
    }

    //瓦斯涌出变化率,传入n小时的数据
    public List<GasAbsoluteEmissionModel> gasEmissiongRadient(List<GasAbsoluteEmissionModel> lists) {
        List<GasAbsoluteEmissionModel> result = new ArrayList<GasAbsoluteEmissionModel>();
        int len = lists.size();
        double xt;//瓦斯涌出量
        double ant = 0;//前n小时的平均瓦斯涌出量
        double i;//瓦斯涌出变化率I
        xt = lists.get(len - 1).getgasAbsEmission();
        for (GasAbsoluteEmissionModel list : lists) {
            ant += list.getgasAbsEmission();
        }
        ant /= lists.size();
        i = xt / ant - 1;
        GasAbsoluteEmissionModel gasAbsoluteEmissionModel =
                new GasAbsoluteEmissionModel(lists.get(len - 1).getDatetime(), lists.get(len - 1).getEntId(), i);
        result.add(gasAbsoluteEmissionModel);
        return result;
    }

    //瓦斯涌出趋势预警指标A
    public double warnings(double v1, double v2, double dt) {
        return Math.abs(v1 - v2) / dt;
    }

}
